#include <stdio.h>
#include <math.h>
#define N 4 
int main()
{
	int nums[N],i,a;
	i=N;
	while(i--)
	{
		scanf("%d",&nums[i]);
	}
	int target;
	scanf("%d",&target);
	int left = 0;
	int right = N - 1;
	int middle = 0;
	while(left <= right)
	{
		middle = (left + right)/2;
		if(nums[middle] < target)
		{
			left = middle + 1;
		}
		else if(nums[middle] > target)
		{
			right = middle - 1;
		}
		else if(nums[middle] == target)
		{
			a=middle;
		}
	}
	printf("%d",middle);
	return -1;
}
